<?php
if(!defined('CMS_ADMIN')) die("Illegal File Access");


$result = $db->sql_query("SELECT content,images,homeimg FROM ".$prefix."_gentext WHERE textname='footmsg' AND alanguage='$currentlang'");
list($content,$images,$homeimg) = $db->sql_fetchrow($result);
$path_upload_img = "$path_upload/temp";
if(isset($_POST['submit'])) {
	$delpic = intval($_POST['delpic']);
	$delpichome = intval($_POST['delpichome']);
	
    if($delpic == 1) {
		@unlink("../$path_upload/temp/$images");
		$images = "";
	}
     if($delpichome == 1) {
		@unlink("../$path_upload/temp/$homeimg");
		$images = "";
	}
   if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
			$upload = new Upload("userfile", $path_upload_img, $maxsize_up);
			$images_up = $upload->send();
			
			if($images_up) {
				@unlink("../$path_upload/temp/$images");
			} else {
				$images_up = $images;
			}
		} else {
			$images_up = $images;
		}
if (is_uploaded_file($_FILES['userhomeimg']['tmp_name'])) {
			$upload = new Upload("userhomeimg", $path_upload_img, $maxsize_up);
			$images_home = $upload->send();
			
			if($images_home) {
				@unlink("../$path_upload/temp/$homeimg");
			} else {
				$images_home = $homeimg;
			}
		} else {
			$images_home = $homeimg;
		}
	$content = strip_tags($content, "<a><b><i><u><font><br><strong><em>");
	$content = $escape_mysql_string($_POST['content']);
	if($db->sql_numrows($result) > 0) {
		$db->sql_query("UPDATE ".$prefix."_gentext SET content='$content',images='$images_up',homeimg='$images_home' WHERE textname='footmsg' AND alanguage='$currentlang'");
	}else{
		$db->sql_query("INSERT INTO ".$prefix."_gentext (textname, content, alanguage,images,homeimg) VALUES ('footmsg', '$content', '$currentlang','$images_up','$images_home')");
	}
	updateadmlog($admin_ar[0], $adm_modname, _SCROLLTEXT, _SAVECHANGES);
	header("Location: modules.php?f=$adm_modname&do=$do&bf");
	exit();
}

include("page_header.php");

echo "<form action=\"modules.php?f=$adm_modname&do=$do\" method=\"POST\" enctype=\"multipart/form-data\"><table border=\"0\" align=\"center\" width=\"98%\" cellspacing=\"0\" cellpadding=\"3\" class=\"tableborder\" >\n";
echo "<tr><td class=\"header\">"._SCROLLTEXT."</td></tr>";
echo "<tr>\n";
echo "<td>";
editor("content",$content);
echo "</td>\n";
echo "</tr>\n";
echo "<tr><td class=\"header\">"._BANNER_WEBSITE."</td></tr>";
echo "<tr>\n";

$bnext = Common::getExt($images);
if($bnext == "swf") {
	echo "<tr>\n";
	echo "<td>";
      echo "<embed width=\"400\" height=\"100\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" wmode=\"transparent\" allowfullscreen=\"false\" scale=\"noborder\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" quality=\"high\" src=\"../$path_upload/temp/$images\" title=\""._BANNER_WEBSITE."\"/>";
    echo "</td>\n";
    	echo "</tr>\n";
}else{
		echo "<tr>\n";
	echo "<td>";
	   echo "<img src=\"../$path_upload/temp/$images\" width=\"400\" height=\"100\" alt=\""._BANNER_WEBSITE."\" />";
	echo "</td>\n";
		echo "</tr>\n";
}
echo "<tr>\n";
	echo "<td>";
	   echo "<span>"._WARNING_IMAGE."</span>";
	echo "</td>\n";
echo "</tr>\n";
if(!empty($images) && file_exists("../$path_upload/temp/$images")) {
	echo "<tr>\n";
	   echo "<td class=\"row2\"><span style=\"font-weight:bold\">"._DELETE_IMAGE."</span><input type=\"checkbox\" name=\"delpic\" value=\"1\"> <a href=\"../$path_upload/temp/$images\" target=\"_blank\"><img border=\"0\" src=\"../images/img.gif\" align=\"absmiddle\"></a></td>\n";
	echo "</tr>\n";
	echo "<tr>\n";
	echo "<td class=\"row2\"><span style=\"font-weight:bold\">"._CHANGE_IMAGE_BANNER."</span><input type=\"file\" name=\"userfile\" size=\"30\"></td>\n";
	echo "</tr>\n";
}else{
echo "<tr>\n";
	echo "<td>";
	echo "<input type=\"file\" name=\"userfile\" size=\"50\">";
	echo "</td>\n";
echo "</tr>\n";
}


/*
 * phan anh va flash trang chu
 * Le duc vien
 */

echo "<tr><td class=\"header\">"._HOMEIMG."</td></tr>";
echo "<tr>\n";

$bnexthome = Common::getExt($homeimg);
if($bnexthome == "swf") {
	echo "<tr>\n";
	echo "<td>";
      echo "<embed width=\"400\" height=\"150\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" wmode=\"transparent\" allowfullscreen=\"false\" scale=\"noborder\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" quality=\"high\" src=\"../$path_upload/temp/$homeimg\" title=\""._HOMEIMG."\"/>";
    echo "</td>\n";
    	echo "</tr>\n";
}else{
		echo "<tr>\n";
	echo "<td>";
	   echo "<img src=\"../$path_upload/temp/$homeimg\" width=\"400\" height=\"150\" alt=\""._IMG_WEBSITE."\" />";
	echo "</td>\n";
		echo "</tr>\n";
}
echo "<tr>\n";
	echo "<td>";
	   echo "<span>"._WARNING_HOMEIMG."</span>";
	echo "</td>\n";
echo "</tr>\n";
if(!empty($homeimg) && file_exists("../$path_upload/temp/$homeimg")) {
	echo "<tr>\n";
	   echo "<td class=\"row2\"><span style=\"font-weight:bold\">"._DELETE_IMAGE."</span><input type=\"checkbox\" name=\"delpichome\" value=\"1\"> <a href=\"../$path_upload/temp/$homeimg\" target=\"_blank\"><img border=\"0\" src=\"../images/img.gif\" align=\"absmiddle\"></a></td>\n";
	echo "</tr>\n";
	echo "<tr>\n";
	echo "<td class=\"row2\"><span style=\"font-weight:bold\">"._CHANGE_IMAGE_HOME."</span><input type=\"file\" name=\"userhomeimg\" size=\"30\"></td>\n";
	echo "</tr>\n";
}else{
echo "<tr>\n";
	echo "<td>";
	echo "<input type=\"file\" name=\"userhomeimg\" size=\"50\">";
	echo "</td>\n";
echo "</tr>\n";
}
echo "<tr><td align=\"center\"><input type=\"submit\" name=\"submit\" value=\""._SAVECHANGES."\" class=\"button2\"></td></tr>";
echo "</table></form><br>";

include("page_footer.php");

?>